/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.web.tsfile.core;

import com.inspur.edp.web.tsfile.api.entity.FileObject;
import com.inspur.edp.web.tsfile.api.webservice.TsFileWebService;
import com.inspur.edp.web.tsfile.core.service.TsFileService4WebApi;

import java.util.HashMap;
import java.util.Map;

/**
 * description: ts文件的操作
 * 提供加载ts文件、创建ts文件及保存ts文件的操作
 *
 * @author Noah Guo
 * @date 2021/01/19
 */
public class TsFileWebServiceImpl implements TsFileWebService {


    @Override
    public Object loadTsFileContent(String path) {

        TsFileService4WebApi service = new TsFileService4WebApi();

        Map<String, Object> map = new HashMap<>();
        map.put("success", true);
        map.put("content", service.loadTsFile(path));
        return map;
    }

    @Override
    public void saveTsFile(String path, FileObject fileObject) {
        TsFileService4WebApi service = new TsFileService4WebApi();
        service.saveTsFile(path, fileObject.content);
    }

    @Override
    public void createTypescriptFile(String path) {
        TsFileService4WebApi service = new TsFileService4WebApi();
        service.createTypescriptFile(path);
    }

    @Override
    public void createMobileTsFile(String path) {
        TsFileService4WebApi service = new TsFileService4WebApi();
        service.createMobileTsFile(path);
    }

}
